home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 3782 < prev    next >
Encoding:
Text File  |  1996-08-06  |  1.4 KB  |  49 lines

  1. Newsgroups: comp.lang.c++
  2. Path: netcom.com!rpl
  3. From: rpl@netcom.com (Robert Laudati)
  4. Subject: Struct as default arg?
  5. Message-ID: <rplDLrDFr.35K@netcom.com>
  6. Organization: NETCOM On-line Communication Services (408 261-4700 guest)
  7. X-Newsreader: TIN [version 1.2 PL1]
  8. Date: Thu, 25 Jan 1996 22:35:51 GMT
  9. Sender: rpl@netcom23.netcom.com
  10.  
  11. I would like to use a structure as a default args as follows:
  12.  
  13. file.h
  14. ======
  15.  
  16. typedef struct { double x; double y; } Point;
  17.  
  18. int Write( int n, char *s, Point p={0.0,0.0} );
  19.  
  20.  
  21. prog.cc
  22. =======
  23.  
  24. status = Write( 34, "String" );      // Output:   34, String, 0.0, 0.0
  25. .
  26. .
  27. .
  28. Point pnt = {110.0, 34.0 };
  29. status = Write( 102, "Label", pnt ); // Output:   102, Label, 110.0, 34.0
  30.  
  31. I get an error compiling stating:
  32.  
  33.  argument list may not have an initializer list
  34. *** Error code 1
  35.  
  36. Is there any way to provide default arguments for a struc in a function?
  37. (There are no classes involved in this example). Thanks,
  38.  
  39. Rob
  40. --
  41. .........................................................
  42. . Robert P. Laudati        rob_laudati@trimble.com    .
  43. . Trimble Navigation Ltd.       rpl@netcom.com          .     
  44. . P.O. Box 3642                (408) 481-8292 voice    .      
  45. . Sunnyvale, CA 94088           (408) 481-8730 fax      .     
  46. .                                                       .
  47. . These views are not necessarily those of Trimble.     .
  48. .........................................................
  49.